﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" 
CodeBehind="Patterns.aspx.cs" Inherits="ElectronicJournal.Account.EditorAccount.Patterns" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="SELECT Title, Description, FileName, Id FROM Patterns ORDER BY Title"
        InsertCommand="INSERT INTO Patterns VALUES(@Title, @Description, @FileName, NEWID())"
        DeleteCommand="DELETE FROM Patterns WHERE Id = @Id">
    <InsertParameters>
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="FileName" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>
    <table>
        <tbody>
            <tr>
                <td>
                    Загруженные шаблоны
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView Width="100%" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" ID="PatternGridView" runat="server" DataSourceId="SqlDataSource1" DataKeyNames="Id" AutoGenerateColumns="false" >
                        <Columns>
                            <asp:BoundField HeaderText="Название шаблона" DataField="Title" SortExpression="Title" />
                            <asp:BoundField HeaderText="Описание шаблона" DataField="Description" SortExpression="Description" />
                            <asp:CommandField SelectText="Загрузить" ShowSelectButton="true" />
                            <asp:CommandField DeleteText="Удалить" ShowDeleteButton="true" />
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:LinkButton runat="server" Text="Добавить шаблон" OnClick="LinkButton_Click"/>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="UploadPanel" runat="server" Visible="false">
                        <table>
                            <tbody>
                                <tr>
                                    <td>
                                        Название:
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="TitleTextBox" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Описание:
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="DescriptionTextBox" TextMode="MultiLine" Width="600" Height="200" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Файл шаблона:
                                    </td>
                                    <td>
                                        <asp:FileUpload ID="FileUpload1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Button ID="Button1" runat="server" Text="Загрузить шаблон" OnClick="Button_Click" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
        </tbody>
    </table>
</asp:Content>
